/* ----------------------------------------------------------------------------
* File: include.h
*
* Desc: Common defines and structures for server/client communications
* ---------------------------------------------------------------------------- */
#ifndef _INCLUDE_H_
#define _INCLUDE_H_

#include <time.h>


#pragma pack(push)  /* push current alignment to stack */
#pragma pack(1)     /* set alignment to 1 byte boundary */


/************************************************************************/
/*	Defines for commands												*/
/************************************************************************/
#define CMD_AUTH				1
#define CMD_GET_USER_INFO		2
#define CMD_GET_BOX_INFO		3

#define CMD_READ_FILE_DATA		4
#define CMD_NEW_FILE_DATA		5
#define CMD_UPDATE_FILE_DATA	6
#define CMD_DELETE_FILE_DATA	7

#define CMD_START_FILE_DATA		100
#define CMD_FILE_DATA			101
#define CMD_END_FILE_DATA		102

#define CMD_ERROR				200


/************************************************************************/
/*	Structure to describe transaction header							*/
/************************************************************************/
typedef struct box_trans_header
{
	unsigned long cmd;			// command identifier
								// one of CMD_xxx
	unsigned long param1;		// some parameter
	unsigned long param2;		// some parameter
	unsigned long data_len;		// data length
	unsigned int time1970;		// time
}box_trans_header;


/************************************************************************/
/*	Structure to describe file info										*/
/************************************************************************/
typedef struct file_info
{
	unsigned int id;		// identifier
	unsigned int id_parent;	// identifier of parent file(directory)
	char name[256];			// file name
	bool is_exist;			// file is exist or isn't
	bool is_access;			// accessibility of file
	size_t size;			// total size, in bytes
	bool is_directory;		// directory flag
	time_t atime;		// time of last access
	time_t mtime;		// time of last modification
	time_t ctime;		// time of last status change
}file_info;


/************************************************************************/
/*	Structure to describe box info										*/
/************************************************************************/
typedef struct box_info
{
	size_t num_files;
}box_info;


/************************************************************************/
/*	Structure to describe user info										*/
/************************************************************************/
typedef struct user_info
{
	char user_name[128];
	size_t num_boxes;
}user_info;


#pragma pack(pop)   /* restore original alignment from stack */

#endif // _INCLUDE_H_